package com.zhz.thymeleafdemo.config;

import com.zhz.thymeleafdemo.intercept.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyConfig implements WebMvcConfigurer {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        String[] excludePathPatterns = {"/login","/"}; //不拦截的路径
        String[] pathPaterns = {"/user/**"}; //需要拦截的路径
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns(pathPaterns)
                .excludePathPatterns(excludePathPatterns);
    }
}
